package onlineLanguageQuizSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("PUT")
        url("/api/v3/onlineLanguageSubmission/callback/1") {
            queryParameters {
                parameter("buildNumber", 1)
                parameter("status", 2)
            }
        }
    }
    response {
        status(201)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
            {
                "id":1,
                "assignmentId":1,
                "quizId":1,
                "userId":1,
                "userAnswer":"asdas",
                "submitTime":12345678,
                "status":2,
                "result":"SUCCESS",
                "answerLanguage":"java",
                "buildNumber":1
            }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.submitTime', byRegex("[\\s\\S]+"))
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.result', byRegex("[\\s\\S]+"))
            jsonPath('$.answerLanguage', byRegex("[\\s\\S]+"))
            jsonPath('$.buildNumber', byRegex(number()))
        }
    }
}
